<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/22
 * Time: 19:02
 */

namespace app\oa\service;

use Flc\Alidayu\Client;
use Flc\Alidayu\App;
use Flc\Alidayu\Requests\AlibabaAliqinFcSmsNumSend;

class Message
{

    public $client;
    public $req;

    function __construct()
    {
        $this->client = new Client(new App(config('alidayu')));
        $this->req = new AlibabaAliqinFcSmsNumSend;
        $this->req->setSmsFreeSignName('自家菜园');
    }

    public function pickup($number, $name, $address)
    {
        $this->req
            ->setSmsTemplateCode('SMS_53205290')
            ->setRecNum($number)
            ->setSmsParam([
                'username' => $name,
                'address' => $address
            ]);
        return $this->client->execute($this->req);
    }

    public function send()
    {
        $config = [
            'app_key' => '23423512',
            'app_secret' => '248452cae29958580d12a3a1f300fce4',
        ];

        $client = new Client(new App($config));
        $req = new AlibabaAliqinFcSmsNumSend;

        $req->setRecNum('15640380127')
            ->setSmsParam([
                'username' => '蒋佳林',
                'address' => '自家菜园'
            ])
            ->setSmsFreeSignName('自家菜园')
            ->setSmsTemplateCode('SMS_53205290');

        $resp = $client->execute($req);

        print_r($resp);
        print_r($resp->result->model);
    }
}